<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="ss" uri="/WEB-INF/stripes-security.tld" %>
<s:layout-render name="/layout.jsp" title="${detail.region}">
    <s:layout-component name="menu"></s:layout-component>
    <s:layout-component name="main_content">
        <s:useActionBean var="ab" beanclass="cz.muni.fi.pa165.creatures.web.RegionsActionBean"/>    
        <div class="main-content">
            <div class="content">
                 <ss:secure roles="admin">
                <img src="${pageContext.request.contextPath}/images/banner-admin.png" alt="Banner" id="banner"/>                
                </ss:secure>
                <ss:secure roles="user">
                <img src="${pageContext.request.contextPath}/images/banner-scout.png" alt="Banner" id="banner"/>                
                </ss:secure>
                <h1><f:message key="detail.region"/></h1>
                <s:form beanclass="cz.muni.fi.pa165.creatures.web.RegionsActionBean">
                    <table>
                        <tbody>
                            <tr>
                                <th><f:message key="regionDTO.name"/></th>
                                <td><s:text readonly="true" name="regionDTO.name"/></td>
                            </tr>
                            <tr>
                                <th><f:message key="regionDTO.description"/></th>
                                <td><s:text readonly="true"  name="regionDTO.description"/></td>
                            </tr>
                            <tr>
                                <th><f:message key="regionDTO.area"/></th>
                                <td><s:text readonly="true" name="regionDTO.area"/></td>
                            </tr>
                            <tr>
                                <th><f:message key="region.creaturesCount"/></th>
                                <td><s:text readonly="true" name="regionDTO.creaturesCount"/></td>
                            </tr>
                        </tbody>
                    </table>
                            
                    <h2><f:message key="region.creaturesOfRegion"/></h2>      
                    
                    <table>
                        <thead>
                            <tr>
                                <th><f:message key="creature.name"/></th>
                                <th><f:message key="creature.type"/></th>
                                <th><f:message key="creature.region"/></th>
                                <th><f:message key="creature.weight"/></th>
                                <th><f:message key="creature.height"/></th>
                                <th><f:message key="creature.hp"/></th>
                            </tr>
                        </thead>
                        <tbody>
                            <c:choose>
                                <c:when test="${regionDTO.creaturesCount != '0'}">
                                    <c:forEach items="${ab.creaturesOfRegion}" var="c">
                                        <tr>
                                            <td><c:out value="${c.name}"/></td>
                                            <td><c:out value="${c.creatureTypeDTO.name}"/></td>
                                            <td><c:out value="${c.regionDTO.name}"/></td>
                                            <td><c:out value="${c.weight}"/></td>
                                            <td><c:out value="${c.height}"/></td>
                                            <td><c:out value="${c.actualHitPoints}"/></td>
                                        </tr>
                                    </c:forEach>
                                </c:when>
                                <c:otherwise>
                                    <tr>
                                        <td colspan="8"><f:message key="creature.no_records_found"/></td>
                                    </tr>
                                </c:otherwise>
                            </c:choose>
                        </tbody>
                    </table>
                    <s:submit name="back"><f:message key="back"/></s:submit>
                </s:form>
            </div>
        </div>
    </s:layout-component>
</s:layout-render>